home *** CD-ROM | disk | FTP | other *** search
/ TeX 1995 July / TeX CD-ROM July 1995 (Disc 1)(Walnut Creek)(1995).ISO / biblio / bibtex / contrib / bbs.bst (.txt) < prev    next >
LaTeX Document  |  1992-07-19  |  24KB  |  930 lines

  1. %%% ====================================================================
  2. %%%  @BibTeX-style-file{
  3. %%%     author          = "Alan Rogers",
  4. %%%     version         = "1.1",
  5. %%%     date            = "Feb 15, 1991",
  6. %%%     filename        = "bbs.bst",
  7. %%%     address         = "Dept of Anthropology, University of Utah,
  8. %%%                        Salt Lake City, UT 84112",
  9. %%%     checksum        = "63919 1162 3279 24277",
  10. %%%     email           = "rogers@anthro.utah.edu",
  11. %%%     supported       = "no",
  12. %%%     docstring       = "The file produces bibliographies more or
  13. %%%                        less in the format of Behavioral and Brain
  14. %%%                        Sciences.  It was adapted from apalike.bst,
  15. %%%                        incorporating features of Sake J.
  16. %%%                        Hogeveen's `astron.bst'.
  17. %%%                        Usage: \documentstyle[astron]{...}
  18. %%%                        ...
  19. %%%                        \bibliographystyle{bbs}
  20. %%%                        ...
  21. %%%                        The \documentstyle command above invokes
  22. %%%                        Hogeveen's `astron.sty', which must be in
  23. %%%                        TeX's search path.
  24. %%%                        The modifications implement `\cite*{}',
  25. %%%                        which generates references in short form.
  26. %%%                        For example, `Rogers \cite*{...}' would
  27. %%%                        produce `Rogers (1992)'."
  28. %%% }
  29. %%% ====================================================================
  30. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  31. % BibTeX `apalike' bibliography style (24-Jan-88 version)
  32. % Adapted from the `alpha' style, version 0.99a; for BibTeX version 0.99a.
  33. % Copyright (C) 1988, all rights reserved.
  34. % Copying of this file is allowed, provided that if you make any changes at all
  35. % you name it something other than `apalike.bst'.
  36. % This restriction helps ensure that all copies are identical.
  37. % Differences between this style and `alpha' are generally heralded by a `%'.
  38. % The file btxbst.doc has the documentation for alpha.bst.
  39. % This style should be used with the `apalike' LaTeX style (apalike.sty).
  40. % \cite's come out like "(Jones, 1986)" in the text but there are no labels
  41. % in the bibliography, and something like "(1986)" comes out immediately
  42. % after the author.  Author (and editor) names appear as last name, comma,
  43. % initials.  A `year' field is required for every entry, and so is either
  44. % an author (or in some cases, an editor) field or a key field.
  45. % Editorial note:
  46. % Many journals require a style like `apalike', but I strongly, strongly,
  47. % strongly recommend that you not use it if you have a choice---use something
  48. % like `plain' instead.  Mary-Claire van Leunen (A Handbook for Scholars,
  49. % Knopf, 1979) argues convincingly that a style like `plain' encourages better
  50. % writing than one like `apalike'.  Furthermore the strongest arguments for
  51. % using an author-date style like `apalike'---that it's "the most practical"
  52. % (The Chicago Manual of Style, University of Chicago Press, thirteenth
  53. % edition, 1982, pages 400--401)---fall flat on their face with the new
  54. % computer-typesetting technology.  For instance page 401 anachronistically
  55. % states "The chief disadvantage of [a style like `plain'] is that additions
  56. % or deletions cannot be made after the manuscript is typed without changing
  57. % numbers in both text references and list."  LaTeX sidesteps the disadvantage.
  58. % History:
  59. %   15-sep-86    (SK,OP)    Original version, by Susan King and Oren Patashnik.
  60. %   10-nov-86    (OP)    Truncated the sort.key$ string to the correct length
  61. %            in bib.sort.order to eliminate error message.
  62. %   24-jan-88    (OP)    Updated for BibTeX version 0.99a, from alpha.bst 0.99a;
  63. %            apalike now sorts by author, then year, then title;
  64. %            THIS `apalike' VERSION DOES NOT WORK WITH BIBTEX 0.98i.
  65. ENTRY
  66.   { address
  67.     author
  68.     booktitle
  69.     chapter
  70.     edition
  71.     editor
  72.     howpublished
  73.     institution
  74.     journal
  75.     key
  76. %    month        not used in apalike
  77.     note
  78.     number
  79.     organization
  80.     pages
  81.     publisher
  82.     school
  83.     series
  84.     title
  85.     type
  86.     volume
  87.     year
  88.   { label extra.label sort.label }
  89. INTEGERS { output.state before.all mid.sentence after.sentence after.block }
  90. FUNCTION {init.state.consts}
  91. { #0 'before.all :=
  92.   #1 'mid.sentence :=
  93.   #2 'after.sentence :=
  94.   #3 'after.block :=
  95. STRINGS { s t }
  96. FUNCTION {output.nonnull}
  97. { 's :=
  98.   output.state mid.sentence =
  99.     { ", " * write$ }
  100.     { output.state after.block =
  101.     { add.period$ write$
  102.       newline$
  103.       "\newblock " write$
  104.     { output.state before.all =
  105.         'write$
  106.         { add.period$ " " * write$ }
  107.       if$
  108.       if$
  109.       mid.sentence 'output.state :=
  110.     }
  111.   if$
  112. FUNCTION {output}
  113. { duplicate$ empty$
  114.     'pop$
  115.     'output.nonnull
  116.   if$
  117. FUNCTION {output.check}
  118. { 't :=
  119.   duplicate$ empty$
  120.     { pop$ "empty " t * " in " * cite$ * warning$ }
  121.     'output.nonnull
  122.   if$
  123. %                    apalike needs this function because
  124. %                    the year has special punctuation;
  125. %                    apalike ignores the month
  126. FUNCTION {output.year.check}
  127. { year empty$
  128.     { "empty year in " cite$ * warning$ }
  129.     { write$
  130.       " (" year * extra.label * ")" *
  131.       mid.sentence 'output.state :=
  132.     }
  133.   if$
  134. FUNCTION {output.bibitem}
  135. { newline$
  136.   "\bibitem[" write$
  137.   label write$
  138.   "]{" write$
  139.   cite$ write$
  140.   "}" write$
  141.   newline$
  142.   before.all 'output.state :=
  143. FUNCTION {fin.entry}
  144. { add.period$
  145.   write$
  146.   newline$
  147. FUNCTION {new.block}
  148. { output.state before.all =
  149.     'skip$
  150.     { after.block 'output.state := }
  151.   if$
  152. FUNCTION {new.sentence}
  153. { output.state after.block =
  154.     'skip$
  155.     { output.state before.all =
  156.     'skip$
  157.     { after.sentence 'output.state := }
  158.       if$
  159.     }
  160.   if$
  161. FUNCTION {not}
  162. {   { #0 }
  163.     { #1 }
  164.   if$
  165. FUNCTION {and}
  166. {   'skip$
  167.     { pop$ #0 }
  168.   if$
  169. FUNCTION {or}
  170. {   { pop$ #1 }
  171.     'skip$
  172.   if$
  173. FUNCTION {new.block.checkb}
  174. { empty$
  175.   swap$ empty$
  176.   and
  177.     'skip$
  178.     'new.block
  179.   if$
  180. FUNCTION {field.or.null}
  181. { duplicate$ empty$
  182.     { pop$ "" }
  183.     'skip$
  184.   if$
  185. FUNCTION {emphasize}
  186. { duplicate$ empty$
  187.     { pop$ "" }
  188.     { "{\em " swap$ * "}" * }
  189.   if$
  190. INTEGERS { nameptr namesleft numnames }
  191. FUNCTION {format.names}
  192. { 's :=
  193.   #1 'nameptr :=
  194.   s num.names$ 'numnames :=
  195.   numnames 'namesleft :=
  196.     { namesleft #0 > }
  197.     { s nameptr "{vv~}{ll}{, jj}{, f.}" format.name$ 't :=   % last name first
  198.       nameptr #1 >
  199.     { namesleft #1 >
  200.         { ", " * t * }
  201.         { numnames #2 >
  202.         { "," * }
  203.         'skip$
  204.           if$
  205.           t "others" =
  206.         { " et~al." * }
  207.         { " \& " * t * }
  208.           if$
  209.         }
  210.       if$
  211.       if$
  212.       nameptr #1 + 'nameptr :=
  213.       namesleft #1 - 'namesleft :=
  214.     }
  215.   while$
  216. FUNCTION {format.ed.names}
  217. { 's :=
  218.   #1 'nameptr :=
  219.   s num.names$ 'numnames :=
  220.   numnames 'namesleft :=
  221.     { namesleft #0 > }
  222.     { s nameptr "{f. }{vv~}{ll}{, jj}" format.name$ 't :=   % last name first
  223.       nameptr #1 >
  224.     { namesleft #1 >
  225.         { ", " * t * }
  226.         { numnames #2 >
  227.         { "," * }
  228.         'skip$
  229.           if$
  230.           t "others" =
  231.         { " et~al." * }
  232.         { " \& " * t * }
  233.           if$
  234.         }
  235.       if$
  236.       if$
  237.       nameptr #1 + 'nameptr :=
  238.       namesleft #1 - 'namesleft :=
  239.     }
  240.   while$
  241. FUNCTION {format.authors}
  242. { author empty$
  243.     { "" }
  244.     { author format.names }
  245.   if$
  246. FUNCTION {format.key}            % this function is just for apalike
  247. { empty$
  248.     { key field.or.null }
  249.     { "" }
  250.   if$
  251. FUNCTION {format.editors}
  252. { editor empty$
  253.     { "" }
  254.     { output.state mid.sentence =
  255.         {"ed. " editor format.ed.names *    }
  256.         { editor format.ed.names  ", ed." * }
  257.       if$
  258.     }
  259.   if$
  260. FUNCTION {format.title}
  261. { title empty$
  262.     { "" }
  263.     { title "t" change.case$ }
  264.   if$
  265. FUNCTION {n.dashify}
  266. { 't :=
  267.     { t empty$ not }
  268.     { t #1 #1 substring$ "-" =
  269.     { t #1 #2 substring$ "--" = not
  270.         { "--" *
  271.           t #2 global.max$ substring$ 't :=
  272.         }
  273.         {   { t #1 #1 substring$ "-" = }
  274.         { "-" *
  275.           t #2 global.max$ substring$ 't :=
  276.           while$
  277.         }
  278.       if$
  279.     { t #1 #1 substring$ *
  280.       t #2 global.max$ substring$ 't :=
  281.       if$
  282.     }
  283.   while$
  284. FUNCTION {format.btitle}
  285. { title emphasize
  286. FUNCTION {tie.or.space.connect}
  287. { duplicate$ text.length$ #3 <
  288.     { "~" }
  289.     { " " }
  290.   if$
  291.   swap$ * *
  292. FUNCTION {either.or.check}
  293. { empty$
  294.     'pop$
  295.     { "can't use both " swap$ * " fields in " * cite$ * warning$ }
  296.   if$
  297. FUNCTION {format.bvolume}
  298. { volume empty$
  299.     { "" }
  300.     { "volume" volume tie.or.space.connect
  301.       series empty$
  302.     'skip$
  303.     { " of " * series emphasize * }
  304.       if$
  305.       "volume and number" number either.or.check
  306.     }
  307.   if$
  308. FUNCTION {format.number.series}
  309. { volume empty$
  310.     { number empty$
  311.     { series field.or.null }
  312.     { output.state mid.sentence =
  313.         { "number" }
  314.         { "Number" }
  315.       if$
  316.       number tie.or.space.connect
  317.       series empty$
  318.         { "there's a number but no series in " cite$ * warning$ }
  319.         { " in " * series * }
  320.       if$
  321.       if$
  322.     }
  323.     { "" }
  324.   if$
  325. FUNCTION {format.edition}
  326. { edition empty$
  327.     { "" }
  328.     { output.state mid.sentence =
  329.     { "(" edition  "l" change.case$ * " ed.)" * }
  330.     { "(" edition  "t" change.case$ * " ed.)" * }
  331.       if$
  332.     }
  333.   if$
  334. INTEGERS { multiresult }
  335. FUNCTION {multi.page.check}
  336. { 't :=
  337.   #0 'multiresult :=
  338.     { multiresult not
  339.       t empty$ not
  340.       and
  341.     }
  342.     { t #1 #1 substring$
  343.       duplicate$ "-" =
  344.       swap$ duplicate$ "," =
  345.       swap$ "+" =
  346.       or or
  347.     { #1 'multiresult := }
  348.     { t #2 global.max$ substring$ 't := }
  349.       if$
  350.     }
  351.   while$
  352.   multiresult
  353. FUNCTION {format.pages}
  354. { pages empty$
  355.     { "" }
  356.     { pages multi.page.check
  357.     { "pages" pages n.dashify tie.or.space.connect }
  358.     { "page" pages tie.or.space.connect }
  359.       if$
  360.     }
  361.   if$
  362. FUNCTION {format.vol.num.pages}
  363. { volume field.or.null
  364.   number empty$
  365.     'skip$
  366.     { "(" number * ")" * *
  367.       volume empty$
  368.     { "there's a number but no volume in " cite$ * warning$ }
  369.     'skip$
  370.       if$
  371.     }
  372.   if$
  373.   pages empty$
  374.     'skip$
  375.     { duplicate$ empty$
  376.     { pop$ format.pages }
  377.     { ":" * pages n.dashify * }
  378.       if$
  379.     }
  380.   if$
  381. FUNCTION {format.chapter.pages}
  382. { chapter empty$
  383.     'format.pages
  384.     { type empty$
  385.     { "chapter" }
  386.     { type "l" change.case$ }
  387.       if$
  388.       chapter tie.or.space.connect
  389.       pages empty$
  390.     'skip$
  391.     { ", " * format.pages * }
  392.       if$
  393.     }
  394.   if$
  395. FUNCTION {format.in.ed.booktitle}
  396. { booktitle empty$
  397.     { "" }
  398.     { editor empty$
  399.     { "In: " booktitle emphasize * }
  400.     { "In: " booktitle emphasize * ", " * format.editors * }
  401.       if$
  402.     }
  403.   if$
  404. FUNCTION {format.thesis.type}
  405. { type empty$
  406.     'skip$
  407.     { pop$
  408.       type "t" change.case$
  409.     }
  410.   if$
  411. FUNCTION {format.tr.number}
  412. { type empty$
  413.     { "Technical Report" }
  414.     'type
  415.   if$
  416.   number empty$
  417.     { "t" change.case$ }
  418.     { number tie.or.space.connect }
  419.   if$
  420. FUNCTION {format.article.crossref}
  421. { "In"                            % this is for apalike
  422.   " \cite{" * crossref * "}" *
  423. FUNCTION {format.book.crossref}
  424. { volume empty$
  425.     { "empty volume in " cite$ * "'s crossref of " * crossref * warning$
  426.       "In "
  427.     }
  428.     { "Volume" volume tie.or.space.connect
  429.       " of " *
  430.     }
  431.   if$
  432.   "\cite{" * crossref * "}" *                % this is for apalike
  433. FUNCTION {format.incoll.inproc.crossref}
  434. { "In"                            % this is for apalike
  435.   " \cite{" * crossref * "}" *
  436. FUNCTION {article}
  437. { output.bibitem
  438.   format.authors "author" output.check
  439.   author format.key output                % special for
  440.   output.year.check                    % apalike
  441.   new.block
  442.   format.title "title" output.check
  443.   new.block
  444.   crossref missing$
  445.     { journal emphasize "journal" output.check
  446.       format.vol.num.pages output
  447.     }
  448.     { format.article.crossref output.nonnull
  449.       format.pages output
  450.     }
  451.   if$
  452.   new.block
  453.   note output
  454.   fin.entry
  455. FUNCTION {book}
  456. { output.bibitem
  457.   author empty$
  458.     { format.editors "author and editor" output.check
  459.       editor format.key output
  460.     }
  461.     { format.authors output.nonnull
  462.       crossref missing$
  463.     { "author and editor" editor either.or.check }
  464.     'skip$
  465.       if$
  466.     }
  467.   if$
  468.   output.year.check                % special for apalike
  469.   new.block
  470.   format.btitle "title" output.check
  471.   format.edition output
  472.   crossref missing$
  473.     { format.bvolume output
  474.       new.block
  475.       format.number.series output
  476.       new.sentence
  477.       publisher "publisher" output.check
  478. %      address output
  479.     }
  480.     { new.block
  481.       format.book.crossref output.nonnull
  482.     }
  483.   if$
  484.   new.block
  485.   note output
  486.   fin.entry
  487. FUNCTION {booklet}
  488. { output.bibitem
  489.   format.authors output
  490.   author format.key output                % special for
  491.   output.year.check                    % apalike
  492.   new.block
  493.   format.title "title" output.check
  494.   new.block
  495.   howpublished output
  496.   address output
  497.   new.block
  498.   note output
  499.   fin.entry
  500. FUNCTION {inbook}
  501. { output.bibitem
  502.   author empty$
  503.     { format.editors "author and editor" output.check
  504.       editor format.key output
  505.     }
  506.     { format.authors output.nonnull
  507.       crossref missing$
  508.     { "author and editor" editor either.or.check }
  509.     'skip$
  510.       if$
  511.     }
  512.   if$
  513.   output.year.check                % special for apalike
  514.   new.block
  515.   format.btitle "title" output.check
  516.   format.edition output
  517.   crossref missing$
  518.     { format.bvolume output
  519.       format.chapter.pages "chapter and pages" output.check
  520.       new.block
  521.       format.number.series output
  522.       new.sentence
  523.       publisher "publisher" output.check
  524. %      address output
  525.     }
  526.     { format.chapter.pages "chapter and pages" output.check
  527.       new.block
  528.       format.book.crossref output.nonnull
  529.     }
  530.   if$
  531.   new.block
  532.   note output
  533.   fin.entry
  534. FUNCTION {incollection}
  535. { output.bibitem
  536.   format.authors "author" output.check
  537.   author format.key output                % special for
  538.   output.year.check                    % apalike
  539.   new.block
  540.   format.title "title" output.check
  541.   new.block
  542.   crossref missing$
  543.     { format.in.ed.booktitle "booktitle" output.check
  544.       format.edition output
  545.       format.bvolume output
  546.       format.number.series output
  547.       format.chapter.pages output
  548.       new.sentence
  549.       publisher "publisher" output.check
  550. %      address output
  551.     }
  552.     { format.incoll.inproc.crossref output.nonnull
  553.       format.chapter.pages output
  554.     }
  555.   if$
  556.   new.block
  557.   note output
  558.   fin.entry
  559. FUNCTION {inproceedings}
  560. { output.bibitem
  561.   format.authors "author" output.check
  562.   author format.key output                % special for
  563.   output.year.check                    % apalike
  564.   new.block
  565.   format.title "title" output.check
  566.   new.block
  567.   crossref missing$
  568.     { format.in.ed.booktitle "booktitle" output.check
  569.       format.bvolume output
  570.       format.number.series output
  571.       format.pages output
  572. %      address output                    % for apalike
  573.       new.sentence                    % there's no year
  574.       organization output                % here so things
  575.       publisher output                    % are simpler
  576.     }
  577.     { format.incoll.inproc.crossref output.nonnull
  578.       format.pages output
  579.     }
  580.   if$
  581.   new.block
  582.   note output
  583.   fin.entry
  584. FUNCTION {conference} { inproceedings }
  585. FUNCTION {manual}
  586. { output.bibitem
  587.   format.authors output
  588.   author format.key output                % special for
  589.   output.year.check                    % apalike
  590.   new.block
  591.   format.btitle "title" output.check
  592.   format.edition output
  593.   organization address new.block.checkb
  594.   organization output
  595. %  address output
  596.   new.block
  597.   note output
  598.   fin.entry
  599. FUNCTION {mastersthesis}
  600. { output.bibitem
  601.   format.authors "author" output.check
  602.   author format.key output                % special for
  603.   output.year.check                    % apalike
  604.   new.block
  605.   format.title "title" output.check
  606.   new.block
  607.   "Master's thesis" format.thesis.type output.nonnull
  608.   school "school" output.check
  609. %  address output
  610.   new.block
  611.   note output
  612.   fin.entry
  613. FUNCTION {misc}
  614. { output.bibitem
  615.   format.authors output
  616.   author format.key output                % special for
  617.   output.year.check                    % apalike
  618.   new.block
  619.   format.title output
  620.   new.block
  621.   howpublished output
  622.   new.block
  623.   note output
  624.   fin.entry
  625. FUNCTION {phdthesis}
  626. { output.bibitem
  627.   format.authors "author" output.check
  628.   author format.key output                % special for
  629.   output.year.check                    % apalike
  630.   new.block
  631.   format.btitle "title" output.check
  632.   new.block
  633.   "PhD thesis" format.thesis.type output.nonnull
  634.   school "school" output.check
  635. %  address output
  636.   new.block
  637.   note output
  638.   fin.entry
  639. FUNCTION {proceedings}
  640. { output.bibitem
  641.   format.editors output
  642.   editor format.key output                % special for
  643.   output.year.check                    % apalike
  644.   new.block
  645.   format.btitle "title" output.check
  646.   format.bvolume output
  647.   format.number.series output
  648. %  address output                % for apalike
  649.   new.sentence                    % we always output
  650.   organization output                % a nonempty organization
  651.   publisher output                % here
  652.   new.block
  653.   note output
  654.   fin.entry
  655. FUNCTION {techreport}
  656. { output.bibitem
  657.   format.authors "author" output.check
  658.   author format.key output                % special for
  659.   output.year.check                    % apalike
  660.   new.block
  661.   format.title "title" output.check
  662.   new.block
  663.   format.tr.number output.nonnull
  664.   institution "institution" output.check
  665. %  address output
  666.   new.block
  667.   note output
  668.   fin.entry
  669. FUNCTION {unpublished}
  670. { output.bibitem
  671.   format.authors "author" output.check
  672.   author format.key output                % special for
  673.   output.year.check                    % apalike
  674.   new.block
  675.   format.title "title" output.check
  676.   new.block
  677.   note "note" output.check
  678.   fin.entry
  679. FUNCTION {default.type} { misc }
  680. MACRO {jan} {"January"}
  681. MACRO {feb} {"February"}
  682. MACRO {mar} {"March"}
  683. MACRO {apr} {"April"}
  684. MACRO {may} {"May"}
  685. MACRO {jun} {"June"}
  686. MACRO {jul} {"July"}
  687. MACRO {aug} {"August"}
  688. MACRO {sep} {"September"}
  689. MACRO {oct} {"October"}
  690. MACRO {nov} {"November"}
  691. MACRO {dec} {"December"}
  692. MACRO {acmcs} {"ACM Computing Surveys"}
  693. MACRO {acta} {"Acta Informatica"}
  694. MACRO {cacm} {"Communications of the ACM"}
  695. MACRO {ibmjrd} {"IBM Journal of Research and Development"}
  696. MACRO {ibmsj} {"IBM Systems Journal"}
  697. MACRO {ieeese} {"IEEE Transactions on Software Engineering"}
  698. MACRO {ieeetc} {"IEEE Transactions on Computers"}
  699. MACRO {ieeetcad}
  700.  {"IEEE Transactions on Computer-Aided Design of Integrated Circuits"}
  701. MACRO {ipl} {"Information Processing Letters"}
  702. MACRO {jacm} {"Journal of the ACM"}
  703. MACRO {jcss} {"Journal of Computer and System Sciences"}
  704. MACRO {scp} {"Science of Computer Programming"}
  705. MACRO {sicomp} {"SIAM Journal on Computing"}
  706. MACRO {tocs} {"ACM Transactions on Computer Systems"}
  707. MACRO {tods} {"ACM Transactions on Database Systems"}
  708. MACRO {tog} {"ACM Transactions on Graphics"}
  709. MACRO {toms} {"ACM Transactions on Mathematical Software"}
  710. MACRO {toois} {"ACM Transactions on Office Information Systems"}
  711. MACRO {toplas} {"ACM Transactions on Programming Languages and Systems"}
  712. MACRO {tcs} {"Theoretical Computer Science"}
  713. FUNCTION {sortify}
  714. { purify$
  715.   "l" change.case$
  716. INTEGERS { len }
  717. FUNCTION {chop.word}
  718. { 's :=
  719.   'len :=
  720.   s #1 len substring$ =
  721.     { s len #1 + global.max$ substring$ }
  722.     's
  723.   if$
  724. %            There are three apalike cases: one person (Jones),
  725. %            two (Jones and de~Bruijn), and more (Jones et~al.).
  726. %            This function is much like format.crossref.editors.
  727. FUNCTION {format.lab.names}
  728. { 's :=
  729.   s #1 "{vv~}{ll}" format.name$
  730.   s num.names$ duplicate$
  731.   #2 >
  732.     { pop$ " et~al." * }
  733.     { #2 <
  734.     'skip$
  735.     { s #2 "{ff }{vv }{ll}{ jj}" format.name$ "others" =
  736.         { " et~al." * }
  737.         { " and " * s #2 "{vv~}{ll}" format.name$ * }
  738.       if$
  739.       if$
  740.     }
  741.   if$
  742. FUNCTION {author.key.label}
  743. { author empty$
  744.     { key empty$
  745.     { cite$ #1 #3 substring$ }
  746.     'key                    % apalike uses the whole key
  747.       if$
  748.     }
  749.     { author format.lab.names }
  750.   if$
  751. FUNCTION {author.editor.key.label}
  752. { author empty$
  753.     { editor empty$
  754.     { key empty$
  755.         { cite$ #1 #3 substring$ }
  756.         'key                % apalike uses the whole key
  757.       if$
  758.     { editor format.lab.names }
  759.       if$
  760.     }
  761.     { author format.lab.names }
  762.   if$
  763. FUNCTION {editor.key.label}
  764. { editor empty$
  765.     { key empty$
  766.     { cite$ #1 #3 substring$ }
  767.     'key            % apalike uses the whole key, no organization
  768.       if$
  769.     }
  770.     { editor format.lab.names }
  771.   if$
  772. FUNCTION {calc.label}      % this function came from ASTRON.BST (ARR)
  773. { type$ "book" =
  774.   type$ "inbook" =
  775.     'author.editor.key.label
  776.     { type$ "proceedings" =
  777.         'editor.key.label                       % apalike ignores organization
  778.         'author.key.label                       % for labeling and sorting
  779.       if$
  780.     }
  781.   if$
  782.   "\protect\astroncite{" swap$ * "}{"                   % these three lines are
  783.   *                                                     % for apalike, which
  784.   year field.or.null purify$ #-1 #4 substring$          % uses all four digits
  785.   *                       % the mathing closing "}" comes in at the reverse.pass
  786.   'label :=
  787. FUNCTION {sort.format.names}
  788. { 's :=
  789.   #1 'nameptr :=
  790.   s num.names$ 'numnames :=
  791.   numnames 'namesleft :=
  792.     { namesleft #0 > }
  793.     { nameptr #1 >
  794.     { "   " * }
  795.     'skip$
  796.       if$                        % apalike uses initials
  797.       s nameptr "{vv{ } }{ll{ }}{  f{ }}{  jj{ }}" format.name$ 't := % <= here
  798.       nameptr numnames = t "others" = and
  799.     { "et al" * }
  800.     { t sortify * }
  801.       if$
  802.       nameptr #1 + 'nameptr :=
  803.       namesleft #1 - 'namesleft :=
  804.     }
  805.   while$
  806. FUNCTION {sort.format.title}
  807. { 't :=
  808.   "A " #2
  809.     "An " #3
  810.       "The " #4 t chop.word
  811.     chop.word
  812.   chop.word
  813.   sortify
  814.   #1 global.max$ substring$
  815. FUNCTION {author.sort}
  816. { author empty$
  817.     { key empty$
  818.     { "to sort, need author or key in " cite$ * warning$
  819.       ""
  820.     { key sortify }
  821.       if$
  822.     }
  823.     { author sort.format.names }
  824.   if$
  825. FUNCTION {author.editor.sort}
  826. { author empty$
  827.     { editor empty$
  828.     { key empty$
  829.         { "to sort, need author, editor, or key in " cite$ * warning$
  830.           ""
  831.         }
  832.         { key sortify }
  833.       if$
  834.     { editor sort.format.names }
  835.       if$
  836.     }
  837.     { author sort.format.names }
  838.   if$
  839. FUNCTION {editor.sort}
  840. { editor empty$
  841.     { key empty$
  842.     { "to sort, need editor or key in " cite$ * warning$
  843.       ""
  844.     { key sortify }
  845.       if$
  846.     }
  847.     { editor sort.format.names }
  848.   if$
  849. %            apalike uses two sorting passes; the first one sets the
  850. %            labels so that the `a's, `b's, etc. can be computed;
  851. %            the second pass puts the references in "correct" order.
  852. %            The presort function is for the first pass. It computes
  853. %            label, sort.label, and title, and then concatenates.
  854. FUNCTION {presort}
  855. { calc.label
  856.   label sortify
  857.   "    "
  858.   type$ "book" =
  859.   type$ "inbook" =
  860.     'author.editor.sort
  861.     { type$ "proceedings" =
  862.     'editor.sort
  863.     'author.sort
  864.       if$
  865.     }
  866.   if$
  867.   #1 entry.max$ substring$    % for
  868.   'sort.label :=        % apalike
  869.   sort.label            % style
  870.   "    "
  871.   title field.or.null
  872.   sort.format.title
  873.   #1 entry.max$ substring$
  874.   'sort.key$ :=
  875. ITERATE {presort}
  876. SORT        % by label, sort.label, title---for final label calculation
  877. STRINGS { last.label next.extra }    % apalike labels are only for the text;
  878. INTEGERS { last.extra.num }        % there are none in the bibliography
  879. FUNCTION {initialize.extra.label.stuff}    % and hence there is no `longest.label'
  880. { #0 int.to.chr$ 'last.label :=
  881.   "" 'next.extra :=
  882.   #0 'last.extra.num :=
  883. FUNCTION {forward.pass}
  884. { last.label label =
  885.     { last.extra.num #1 + 'last.extra.num :=
  886.       last.extra.num int.to.chr$ 'extra.label :=
  887.     }
  888.     { "a" chr.to.int$ 'last.extra.num :=
  889.       "" 'extra.label :=
  890.       label 'last.label :=
  891.     }
  892.   if$
  893. FUNCTION {reverse.pass}       % this function came from ASTRON.BST (ARR)
  894. { next.extra "b" =
  895.     { "a" 'extra.label := }
  896.     'skip$
  897.   if$
  898.   label extra.label * "}" * 'label :=
  899.   extra.label 'next.extra :=
  900. EXECUTE {initialize.extra.label.stuff}
  901. ITERATE {forward.pass}
  902. REVERSE {reverse.pass}
  903. %                Now that the label is right we sort for real,
  904. %                on sort.label then year then title.  This is
  905. %                for the second sorting pass.
  906. FUNCTION {bib.sort.order}
  907. { sort.label
  908.   "    "
  909.   year field.or.null sortify
  910.   "    "
  911.   title field.or.null
  912.   sort.format.title
  913.   #1 entry.max$ substring$
  914.   'sort.key$ :=
  915. ITERATE {bib.sort.order}
  916. SORT        % by sort.label, year, title---giving final bibliography order
  917. FUNCTION {begin.bib}
  918. { preamble$ empty$                % no \etalchar in apalike
  919.     'skip$
  920.     { preamble$ write$ newline$ }
  921.   if$
  922.   "\begin{thebibliography}{}" write$ newline$        % no labels in apalike
  923. EXECUTE {begin.bib}
  924. EXECUTE {init.state.consts}
  925. ITERATE {call.type$}
  926. FUNCTION {end.bib}
  927. { newline$
  928.   "\end{thebibliography}" write$ newline$
  929. EXECUTE {end.bib}
  930.